package com.unidt.www.module.third.workbar.controller.admin;

import com.unidt.www.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.unidt.www.framework.common.pojo.CommonResult;
import com.unidt.www.framework.operatelog.core.annotations.OperateLog;
import com.unidt.www.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import com.unidt.www.module.third.workbar.service.IWorkBarLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author sk
 * @Description:
 * @Date 2022/11/28 14:22
 **/
@Api(tags = "工作台-跳转")
@RestController
@RequestMapping("/workbar")
@Slf4j
public class WorkBarAuthLoginController {

    @Autowired
    IWorkBarLoginService iWorkBarLoginService;


    @PostMapping("/getTokenByCode/{code}")
    @ApiOperation("工作台-免登陆token")
    @OperateLog(enable = false)
    public CommonResult<AuthLoginRespVO> getTokenByCode(@PathVariable(value = "code") String code) {
        try {
            AuthLoginRespVO loginRespVO = this.iWorkBarLoginService.loginByCode(code);
            return CommonResult.success(loginRespVO);
        }catch (Exception e){
            log.error("登录失败",e);
        }
        return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(),"登录失败");


    }


}
